def get_str_sha_secret_str(res:str):
    import hashlib
    """
    使用sha加密算法，返回str加密后的字符串
    """
    sha = hashlib.sha256(res.encode('utf-8'))
    encrypts = sha.hexdigest()
    # print(encrypts)
    return encrypts

def write_checksum(s: str):
    logf = "sha256.log"
    from time import asctime
    t = asctime()
    cksum = get_str_sha_secret_str(t+s)
    with open(logf, 'a') as f:
        f.write(f'Time: {t}\nMsg: {s}\nSHA256: {cksum}\n\n')
    return cksum

from sys import argv
if __name__ == "__main__":
    if len(argv) == 2:
        write_checksum(argv[1])
